//
//  RedBagAPI.swift
//  LeGou
//
//  Created by lxm on 2022/10/8.
//
import Foundation

enum RedBagAPI {
    case red_info
    // 排行榜
    case red_rank(_ params : [String : Any])
    // 抢红包
    case rob_bag(_ params : [String : Any])
    // 是否抢过
    case is_robed(_ params : [String : Any])
    // 获取抢红包资格
    case can_rob
    // 红包滚屏
    case red_scroll_info(_ params : [String : Any])
    // 红包收益
    case red_profit_list(_ params : [String : Any])
}

extension RedBagAPI: ZMApiProvider {
    func BaseUrl() -> String {
        return baseUrl
    }
    
    func urlAndMthodAndParam() -> (url: String, method: ZMHTTPMethod, params: [String : Any], body: Bool) {
        switch self {
        case .red_info:
            return ("/api/front/redInfo", .get, [:], false)
        case .red_rank(let pa):
            return ("/api/front/getRankList", .get, pa, false)
        case .rob_bag(let pa):
            return ("/api/front/tryPickRed", .get, pa, false)
        case .is_robed(let pa):
            return ("/api/front/isPicked", .get, pa, false)
        case .can_rob:
            return ("/api/front/readRedPermit", .get, [:], false)
        case .red_scroll_info(let pa):
            return ("/api/front/getRedLogRoll", .get, pa, false)
        case .red_profit_list(let pa):
            return ("/api/front/getUserStat", .get, pa, false)
        }
    }
    
    func HTTPHeader() -> ZMHTTPHeaders? {
        return AppHelper.reqeustHeader()
    }
    
    func UpLoadData() -> [Data]? {
        return nil
    }
    
    func singleRequest() -> Bool {
        switch self {
            case .can_rob:
                return true
            default:
                return false
        }
    }
    
    func ParamInBody() -> Bool {
        switch self {
//            return true
        default:
            return false
        }
    }
}
